<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%>
<c:set var="path" value="..${ctx}/define/view"/>

<div class="pageContent">

	<div class="panelBar">
		<ul class="toolBar">
			<li><a class="edit" onclick="saveViewDetail();" title="保存"><span>保存</span></a></li>
			<li class="line">line</li>
			<li><a class="delete" onclick="deleteViewDetail();"><span>删除</span></a></li>
		</ul>
	</div>

	<form name="action_set_form" method="post" action="${path}/save.html" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone);">
		<input type="hidden" id="actionType" name="actionType" value="${actionType}" />
		<div class="pageFormContent" layoutH="260" >
			<fieldset>
				<dl >
					<dt>视图名称：</dt>
					<dd><input name="name" id="name" type="text" size="60" value="${bean.name}" class="required" /></dd>
				</dl>
				<dl >
					<dt>视图标题：</dt>
					<dd><input name="text" type="text" size="60" value="${bean.text}" class="required" /></dd>
				</dl>
				<dl >
					<dt>视图分类：</dt>
					<dd><input name="sort" type="text" size="60" value="${bean.sort}" class="required" /></dd>
				</dl>
				<dl >
					<dt>视图路径：</dt>
					<dd><input name="path" type="path" size="52" value="${bean.path}" /></dd>
				</dl>		
				<dl class="nowrap">
					<dt>描述：</dt>
					<dd><textarea name="description" cols="80" rows="3">${bean.description}</textarea></dd>
				</dl>
			</fieldset>
		</div>

			<div class="pageFormContent" layoutH="160">
			<div class="tabs">
			<div class="tabsHeader">
				<div class="tabsHeaderContent">
					<ul>
						<li class="selected"><a href="javascript:void(0)"><span>权限配置列表</span></a></li>
					</ul>
				</div>
			</div>
			
			<div class="tabsContent" style="height: 160px;">
				<div>
					<div class="panelBar">
						<ul class="toolBar">
							<li><a class="add" onclick="addjudge();" title="添加"><span>添加</span></a><br /><br /></li>
							<li class="line">line</li>
							<li><a class="edit" onclick="editjudge();" title="修改"><span>修改</span></a></li>
							<li class="line">line</li>
							<li><a class="delete" onclick="deletejudge();"><span>删除</span></a></li>
						</ul>
					</div>

					<table class="table" width="100%" >
						<thead>
							<tr>
								<th width="160">操作单元名称</th>
								<th width="80">分类</th>
								<th width="240">描述</th>
							</tr>

						</thead>
							<tbody id="base_define_action_set_list_tbody">

						</tbody>
					</table>
				</div>

			</div>
			</div>
		</div>
		
	</form>
</div>
<script type="text/javascript">
/**
 * dialog上的表单提交回调函数
 * 服务器转回navTabId，可以重新载入指定的navTab. statusCode=DWZ.statusCode.ok表示操作成功, 自动关闭当前dialog
 * form提交后返回json数据结构,json格式和navTabAjaxDone一致
 */
function dialogAjaxDone(json){
	DWZ.ajaxDone(json);
	if (json.statusCode == DWZ.statusCode.ok){
		// alertMsg.correct(json.message);
		if(json.callbackType){
			var str = $("#name").val();
			var url = "${path}/search.html?name=" + str;
			navTab.reload(url,null,"base_define_view_list");
			// navTab.reload(url);
			//navTab.reloadFlag("base_define_action_list"); // 下次切换到列表页签时需要刷新一下
			setTimeout(function(){$.pdialog.closeCurrent();}, 100); // 关闭此编辑页签
		}
	}
}

function saveViewDetail(){
	$(action_set_form).submit();
}

function deleteViewDetail(){
	var rel = '';
	$('.base_define_view_list_tr').each(function(){
		if($(this).hasClass("selected")){
			rel = $(this).attr('rel');
		}
	});
	if(rel==''){
		alertMsg.warn('请先选择一条数据！');
	}else{
		alertMsg.confirm("确定要删除吗?", {
			okCall: function(){
				var url = "${path}/delete.html?name=" + rel;
				$.ajax({
					type: "post", url: url,
					success: function(json){
						alertMsg.correct(json.msg);
						var url = "${path}/search.html";
						navTab.reload(url);
						setTimeout(function(){$.pdialog.closeCurrent();}, 100); // 关闭此编辑页签
					},
					error: function(){
						alertMsg.error('系统错误，请联系管理员！');
					}
				});
			}
		});
	}
}

function addjudge(action){
	var title = "添加判断";
	var url = "${path}/add.html";
	$.pdialog.open(url, "base_define_judge_add", title,{width:600,height:460,mask:true,maxable:false,resizable:false});
}

function editjudge(){
	var rel = '';
	$('.base_define_judge_list_tr').each(function(){
		if($(this).hasClass("selected")){
			rel = $(this).attr('rel');
		}
	});
	if(rel==''){
		alertMsg.warn('请先选择一条数据！');
	}else{
		var title = "更新判断";
		var url = "${path}/edit.html?id=" + rel;
		$.pdialog.open(url, "base_define_judge_add", title,{width:600,height:460,mask:true,maxable:false,resizable:false});
	}
}

function deletejudge(){
	var rel = '';
	$('.base_define_judge_list_tr').each(function(){
		if($(this).hasClass("selected")){
			rel = $(this).attr('rel');
		}
	});
	if(rel==''){
		alertMsg.warn('请先选择一条数据！');
	}else{
		alertMsg.confirm("确定要删除吗?", {
			okCall: function(){
				var url = "${path}/delete.html?id=" + rel;
				$.ajax({
					type: "post", url: url,
					success: function(json){
						alertMsg.correct(json.msg);
						var url = "${path}/list.html";
						$.pdialog.reload(url);
					},
					error: function(){
						alertMsg.error('系统错误，请联系管理员！');
					}
				});
			}
		});
	}
}

</script>
